<script setup>
import { ref, watch } from 'vue'

const props = defineProps({
  sectionId: Number
})

const videoPlayer = ref(null)

watch(() => props.sectionId, (newVal) => {
  if (newVal && videoPlayer.value) {
    videoPlayer.value.pause()
    // 设置 url
    // videoPlayer.value.src = `...`;
    videoPlayer.value.load()
    videoPlayer.value.play()
  }
})
</script>

<template>
  <div class="video-container">
    <video ref="videoPlayer" controls width="100%" height="100%">
      <source src="@/assets/videos/testVideo.mp4" type="video/mp4">
      您的浏览器不支持视频播放
    </video>
  </div>
</template>

<style scoped>
.video-container {
  width: 80vw;
  height: calc(80vw* 8.5 / 16);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid #eee;
  border-radius: 8px;
  margin: 20px 20px;
}
</style>
